﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8"/>
    <title>草稿</title>
    <script language="JavaScript" src="./Comm/JScript.js" type="text/javascript" ></script>
    <script type="text/javascript" src="./Scripts/bootstrap/js/jquery.min.js"></script>
    <script type="text/javascript" src="./Scripts/bootstrap/js/bootstrap.min.js"></script>
    <script src="./Scripts/QueryString.js" type="text/javascript"></script>
    <script src="./Scripts/config.js" type="text/javascript"></script>
     <base target="_self" />
    <link href="../DataUser/Style/ccbpm.css" rel="stylesheet" type="text/css" />
    <script language="javascript" type="text/javascript" >
        function WinOpenIt(url) {
            //窗口最大化e
            var scrWidth = screen.availWidth;
            var scrHeight = screen.availHeight;
            var self = window.open(url, '_blank', "resizable=1,scrollbars=yes");
            self.moveTo(0, 0);
            self.resizeTo(scrWidth, scrHeight);
            self.focus();
            // var newWindow = window.open(url, '_blank', 'height=600,width=850,top=50,left=50,toolbar=no,menubar=no,scrollbars=yes, resizable=yes,location=no, status=no');
            // newWindow.focus();
            return;
        }

        /* ESC Key Down */
        function Esc() {
            if (event.keyCode == 27)
                window.close();
            return true;
        }

        //页面启动函数.
        $(function () {

            $("#Msg").html("<img src=./Img/loading.gif />&nbsp;正在加载,请稍后......");

            InitPage();

            $("#Msg").html("");
        });

        //初始化数据.
        function InitPage() {

            //初始化表格.
            $.ajax({
                type: 'post',
                async: true,
                url: Handler + "?DoType=Draft_Init&m=" + Math.random(),
                dataType: 'html',
                success: function (data) {

                    if (data.indexOf('err@') == 0) {
                        alert(data);
                        return;
                    }

                    var timeKey = Math.random();
                    data = JSON.parse(data);

                    //增加处理.
                    var idx = 0;
                    for (var i = 0; i < data.length; i++) {

                        idx++;

                        var title = data[i].Title;
                        var flowNo = data[i].FK_Flow;
                        var flowName = data[i].FlowName;
                        var rdt = data[i].RDT;
                        var flowNote = data[i].FlowNote;
                        var workID = data[i].WorkID;
                        var paras = data[i].AtPara; //参数.
                        if (paras != '' && paras != null) {
                            paras = paras.replace("'", "\\'");
                            paras = paras.replace('@', '&');
                            paras = paras.replace('@', '&');
                            paras = paras.replace('@', '&');
                            paras = paras.replace('@', '&');
                            paras = paras.replace('@', '&');
                            paras = "1" + paras;
                        }

                        var newRow = "";
                        newRow = "<tr ><td class=Idx >" + idx + "</td>";
                        newRow += "<td>" + "<a href=\"javascript:WinOpenIt('MyFlow.htm?FK_Flow=" + flowNo + "&FID=0&WorkID=" + workID + "&IsRead=0&Paras=" + paras + "&T=" + timeKey + "');\" ><img src='./Img/Mail_UnRead.png' border=0 />" + title + "</a></td>";
                        newRow += "<td>" + flowName + "</td>";
                        newRow += "<td>" + rdt + "</td>";
                        newRow += "<td>" + flowNote + "</td>";
                        newRow += "<td>";
                        newRow += "<a href=\"javascript:Delete('" + flowNo + "','" + workID + "')\"><img src='./Img/Btn/Delete.gif' border=0 />删除</a>";
                        newRow += "</td>";
                        newRow += "</tr>";

                        $("#Table1 tr:last").after(newRow);
                    }
                }
            });
        }

        //删除流程.
        function Delete(flowNo, workid) {
            if (window.confirm('您确定要删除草稿吗？') == false)
                return;

            //初始化表格.
            $.ajax({
                type: 'post',
                async: true,
                url: Handler + "?DoType=Draft_Delete&FK_Flow=" + flowNo + "&WorkID=" + workid + "&m=" + Math.random(),
                dataType: 'html',
                success: function (data) {

                    if (data.indexOf('err@') == 0) {
                        alert(data);
                        return;
                    }

                    //删除流程.
                    alert(data);

                    window.location.href = window.location.href;
                }
            });
        }
     </script>
</head>
<body onkeypress="Esc()" >

<table id="Table1" style="width:100%;">
<tr>
<th>序</th>
<th>标题</th>
<th>流程</th>
<th>保存日期</th>
<th>备注</th>
<th>操作</th>
</tr>
</table>

<div id="Msg"></div>

</body>
</html>
